import java.io.File;

import trigest.*;
public class SearchAsst {

	/**
	 * @param args
	 */
	/*
	public static void main(String[] args) {
		trigest d1 = null;
		trigest d2 = null;
		
		try{
			d1=new trigest("you");			
		}
		catch (Exception e)
		{
			System.out.println("--- In exception ---");
		}
		
		//printbary(d1.getSignature());
		
		System.out.println(" --- Now printing File Signature --- ");
		try {
			d2=new trigest(new File("C:\\Temp\\test.txt"));
			
		}
		catch (Exception e)
		{
			System.out.println(" In exception");			
		}
		//printbary(d2.getSignature());
		sfcompare(d1.getSignature(),d2.getSignature());
       


	}
	
*/
	public static int sfcompare(byte[] bary, byte[] bary2) {
		//byte [] m = new byte[1];
		//BigInteger b;
		
		int h=0;
		//String s;
		for (int i = 0; i < bary.length;i++){//bary.length; i++) {
			
			/* //System.out.printf("%d",i);
		    int t= bary[i];
			String temp = "0000";
			temp=temp.concat(Integer.toHexString(t));
			temp=temp.toUpperCase();
			System.out.printf("%c%c",temp.charAt(temp.length()-2),temp.charAt(temp.length()-1));
			*/
			
			//System.out.println(i);
			int t1=bary[i];
			int b1=bary2[i];
			String temp2="";//="0000000";
			String temp3="";
			String t2=Integer.toBinaryString(t1);
			String b2=Integer.toBinaryString(b1);
			int len=t2.length();
			int len2=b2.length();
			//System.out.println(temp2.length());
			
			if(len==1)
			temp2="0000000"; //System.out.println("im here");}
			else if(len==2)
			    temp2="000000";
			else if(len==3)
			    temp2="00000";
			else if(len==4)
			    temp2="0000";
			else if(len==5)
			    temp2="000";
			else if(len==6)
			    temp2="00";
			else if(len==7)
			    temp2="0";
			//else
				//temp2="";
		
			
			if(len2==1)
				temp3="0000000"; //System.out.println("im here");}
				else if(len2==2)
				    temp3="000000";
				else if(len2==3)
				    temp3="00000";
				else if(len2==4)
				    temp3="0000";
				else if(len2==5)
				    temp3="000";
				else if(len2==6)
				    temp3="00";
				else if(len2==7)
				    temp3="0";
			
			    	
			
		
			//System.out.println(temp2.length());
			
			//int t3=bary[i];
			temp2=temp2.concat(Integer.toBinaryString(t1));
			//System.out.println(temp2.length());
			//System.out.printf("%c%c%c%c%c%c%c%c ", temp2.charAt(temp2.length()-8),temp2.charAt(temp2.length()-7),temp2.charAt(temp2.length()-6),temp2.charAt(temp2.length()-5),temp2.charAt(temp2.length()-4),temp2.charAt(temp2.length()-3),temp2.charAt(temp2.length()-2),temp2.charAt(temp2.length()-1));
			
            //System.out.printf("im here");
			
			temp3=temp3.concat(Integer.toBinaryString(b1));
			//System.out.printf("%c%c%c%c%c%c%c%c", temp3.charAt(temp3.length()-8),temp3.charAt(temp3.length()-7),temp3.charAt(temp3.length()-6),temp3.charAt(temp3.length()-5),temp3.charAt(temp3.length()-4),temp3.charAt(temp3.length()-3),temp3.charAt(temp3.length()-2),temp3.charAt(temp3.length()-1));
			/*
		    //m[0] = bary[i];  
		    System.out.println (temp2.length());
		    //b= new BigInteger(m);
		  	//s = new String (b.toString(2));
		    */
		  	//System.out.println(temp2.length());
			
			
			for(int k=8;k>0;k--)
			{
				if(temp2.charAt(temp2.length()-k)==temp3.charAt(temp3.length()-k) && temp2.charAt(temp2.length()-k)=='1')
					h++;
					//{System.out.println("wow we actually have a match!!!"); h++; }
				if(temp3.charAt(temp3.length()-k)=='0' && temp2.charAt(temp2.length()-k)=='1')
				{ //  System.out.println("no match");
					//return 0;
				}
			}
			
			
			//System.out.println("");
		}
		System.out.println("counter:"+h);
		//System.out.println("");
		
		//docRank(h);
		//return h;
		//return h;
		return h;
	}

	
	

}
